/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
	
	// 参数配置对象
	const config = vm.vuex_config;
	const timeout = 3000;
	
	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		
		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/'+params.lang, {}, {timeout}),
		index: (params = {}) => vm.$u.get(config.adminPath+'/index', params, {}, {timeout}),
		login: (params = {}) => vm.$u.post(config.adminPath+'/login', params, {}, {timeout}),
		logout: (params = {}) => vm.$u.get(config.adminPath+'/logout', params, {}, {timeout}),
		authInfo: (params = {}) => vm.$u.get(config.adminPath+'/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath+'/menuTree', params),
		menuRoute: (params = {}) => vm.$u.get(config.adminPath+'/menuRoute', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath+'/switch/'+params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath+'/sys/dictData/treeData', params),
		
		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/validCode', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),
		
		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', {appCode: config.appCode, appVersion: config.appVersion}),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),
		
		// 个人信息修改
		user: {
			infoSaveBase: (params = {}) => vm.$u.post(config.adminPath+'/sys/user/infoSaveBase', params),
			infoSavePwd: (params = {}) => vm.$u.post(config.adminPath+'/sys/user/infoSavePwd', params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath+'/sys/user/infoSavePqa', params),
		},
		
		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath+'/sys/empUser/listData', params),
		},
		
		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath+'/sys/office/treeData', params),
		},
		
		//主类型
		mainType: {
			treeData: (params = {}) => vm.$u.get(config.adminPath+'/sys/dictData/listData', params),
		},
		
		// 字典管理（增删改查）
		dictType: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sys/dictData/listData', params),
			save: (params = {}) => vm.$u.post(config.adminPath+'/sys/dictData/save', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/sys/dictData/delete', params),
			form: (params = {}) => vm.$u.post(config.adminPath+'/sys/dictData/form', params),
		},
		
		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath+'/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/test/testData/delete', params),
		},
		// 销售管理
		salesManagement: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/listData', params),
			save: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/save', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/delete', params),
		},
		//月报表
		salesReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupBy', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetail', params),
		},
		//年报表
		yearSalesReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByYear', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetailByMonth', params),
		},
		//分店出票统计
		branchTicketingReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByFd', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetailFd', params),
		},
		//合买出票统计
		jointTicketingReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByHm', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetailHm', params),
		},
		// 佣金报表
		commissionReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByYj', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetail', params),
		},
		//开支报表
		expensesReport: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByKz', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetail', params),
		},
		//店铺交款
		paymentManagement: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByJk', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetailJk', params),
			groupByDetail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/groupByDetail', params),
			update: (params = {}) => vm.$u.post(config.adminPath+'/sale/manageAudit/save', params),
		},
		//工资表
		payroll: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/salary/salary/listData', params),
			calculate: (params = {}) => vm.$u.post(config.adminPath+'/salary/salary/calculate', params),
			save: (params = {}) => vm.$u.post(config.adminPath+'/salary/salary/save', params),
		},
		//排休表管理
		manageAudit: {
			getApprovalInfo: (params = {}) => vm.$u.post(config.adminPath+'/sale/manageAudit/getApprovalInfo', params),
		},
		//审核管理
		reviewManagement: {
			list: (params = {}) => vm.$u.post(config.adminPath+'/sale/manageAudit/listData', params),
			detail: (params = {}) => vm.$u.post(config.adminPath+'/sale/manage/listData', params),
			update: (params = {}) => vm.$u.post(config.adminPath+'/sale/manageAudit/save', params),
		},
		
		// 商品分类管理
		productCategory: {
			save: (params = {}) => vm.$u.post(config.adminPath+'/product/category/save', params),
			list: (params = {}) => vm.$u.post(config.adminPath+'/product/category/listData', params),
			treeData: (params = {}) => vm.$u.post(config.adminPath+'/product/category/treeData', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/product/category/delete', params),
			updateStatus: (params = {}) => vm.$u.post(config.adminPath+'/product/category/updateStatus', params),
			form: (params = {}) => vm.$u.post(config.adminPath+'/product/category/form', params),
			changeSort: (params = {}) => vm.$u.post(config.adminPath+'/product/category/changeSort', params),
		},
		// 商品管理
		productManagement: {
			save: (params = {}) => vm.$u.post(config.adminPath+'/product/product/save', params),
			list: (params = {}) => vm.$u.post(config.adminPath+'/product/product/listData', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/product/product/delete', params),
			updateStatus: (params = {}) => vm.$u.post(config.adminPath+'/product/product/updateStatus', params),
			changeSort: (params = {}) => vm.$u.post(config.adminPath+'/product/product/changeSort', params),
		},
		// 盘点管理
		inventory: {
			init: (params = {}) => vm.$u.post(config.adminPath+'/product/inventory/init', params),
			getItems: (checkId, params = {}) => vm.$u.get(config.adminPath+'/product/inventory/items/'+checkId, params),
			getStatistics: (checkId, params = {}) => vm.$u.get(config.adminPath+'/product/inventory/statistics/'+checkId, params),
			saveItem: (params = {}) => vm.$u.postJson(config.adminPath+'/product/inventory/item/save', params),
			saveItems: (params = {}) => vm.$u.postJson(config.adminPath+'/product/inventory/items/save', params),
			save: (params = {}) => vm.$u.post(config.adminPath+'/product/inventory/save', params),
			complete: (checkId, params = {}) => vm.$u.post(config.adminPath+'/product/inventory/complete/'+checkId, params),
			reset: (checkId, params = {}) => vm.$u.post(config.adminPath+'/product/inventory/reset/'+checkId, params),
			list: (params = {}) => vm.$u.get(config.adminPath+'/product/inventory/listData', params),
			detail: (id, params = {}) => vm.$u.get(config.adminPath+'/product/inventory/detail/'+id, params),
			delete: (id, params = {}) => vm.$u.post(config.adminPath+'/product/inventory/delete/'+id, params),
		},
		// 购物车
		shopcart: {
			list: (params = {}) => vm.$u.get(config.adminPath+'/product/shopcart/list', params),
			updateCart: (params = {}) => vm.$u.post(config.adminPath+'/product/shopcart/updateCart', params),
			clear: (params = {}) => vm.$u.post(config.adminPath+'/product/shopcart/clear', params),
		},
		// 收货地址
		address: {
			list: (params = {}) => vm.$u.get(config.adminPath+'/product/address/list', params),
			save: (params = {}) => vm.$u.post(config.adminPath+'/product/address/save', params),
			delete: (params = {}) => vm.$u.post(config.adminPath+'/product/address/delete', params),
		},
		// 订单管理
		orderManagement: {
			create: (params = {}) => vm.$u.post(config.adminPath+'/product/order/createFromCart', params),
			list: (params = {}) => vm.$u.get(config.adminPath+'/product/order/list', params),
			listByShop: (params = {}) => vm.$u.get(config.adminPath+'/product/order/listByShop', params),
			detail: (params = {}) => vm.$u.get(config.adminPath+'/product/order/detail', params),
			updateStatus: (params = {}) => vm.$u.post(config.adminPath+'/product/order/updateStatus', params),
			payDebt: (params = {}) => vm.$u.post(config.adminPath+'/product/order/paymentSupplement', params),
			paymentApprove: (params = {}) => vm.$u.post(config.adminPath+'/product/order/paymentApprove', params),
		},
		// 钱包管理
		wallet: {
			getBalance: (params = {}) => vm.$u.get(config.adminPath+'/product/wallet/getBalance', params),
			assetsSummary: (params = {}) => vm.$u.get(config.adminPath+'/product/wallet/assetsSummary', params),
			recharge: (params = {}) => vm.$u.post(config.adminPath+'/product/wallet/recharge', params),
			audit: (params = {}) => vm.$u.post(config.adminPath+'/product/wallet/audit', params),
			rechargeList: (params = {}) => vm.$u.get(config.adminPath+'/product/wallet/rechargeList', params),
			pettyCashAdjust: (params = {}) => vm.$u.post(config.adminPath+'/product/wallet/pettyCash/adjust', params),
			list: (params = {}) => vm.$u.get(config.adminPath+'/product/wallet/list', params),
			orderReport: (params = {}) => vm.$u.get(config.adminPath+'/product/wallet/orderReport', params),
		},
	};
	
}

export default {
	install
}